﻿$(function(){//延迟加载
	var parentname=$('#parentname').val();
	var parentId=$('#parentId').val();
	$('#addnewft').propertygrid({
		width:'310px',
		data:{"total":6,"rows":[
		    	                  {'name':'上层功能类别','value':parentname,'group':'ID Settings','editor':{
		    	                	  'editable':false
		    	                  }},
		    	                  {"name":"功能类型","group":"ID Settings","editor":{
		    	                      "type":"validatebox",
		    	                      "options":{
		    	                      "required":true
		    	                     }
		    	                  }},
		    	                  {"name":"请求名称","group":"ID Settings","editor":{
		    	                      "type":"validatebox",
		    	                      "options":{
		    	                      "required":true
		    	                     }    
		    	                  }},
		    	                  {"name":"功能类型种类","group":"ID Settings","editor":{
		    	                      type:'combobox',
		    	                      options:{
		    	                    	required:true,
		    	                      	valueField:'value',
		  								textField:'label',
		  								data: [{
		  									label: 'jsp',
		  									value: 'jsp'
		  								},{
		  									label: 'sort',
		  									value: 'sort'
		  								}]
		    	                     }    
		    	                  }},
		    	                  {"name":"图标选择","group":"ID Settings","editor":{
		    	                	  type:'combobox',
		    	                	  options:{
		  								valueField:'datavalue',
		  								textField:'datavalue',
		  								method:'get',
		  								url:'geticoncls?fieldId=iconcls'
		  							},
		  							required:true
		    	                  }},
		    	                  {"name":"功能类别描述","group":"ID Settings","editor":{
		    	                      "type":"validatebox",
		    	                      "options":{
		    	                    	  
		    	                     }    
		    	                  }},
		    	                  {"name":"功能排序","group":"ID Settings","editor":{
		    	                      "type":"numberbox",
		    	                      "options":{
		    	                      "required":true
		    	                     }
		    	                  }}
		    	              ]},
		columns:[[
		         {'field':'name','title':'新功能类别','width':'120px'},
		         {'field':'value','title':'','width':'170px'}		          		          
		          ]],
		//showHeader:false		    	              
	});
	
	$('#addcompl').linkbutton({
		plain:true,
		iconCls:'icon-ok',
		onClick:function(){
			var functypename=$('#addnewft').propertygrid('getRows')[1].value;
			if(functypename==undefined)
				return;
			var functypecode=$('#addnewft').propertygrid('getRows')[2].value;
			var functypesort=$('#addnewft').propertygrid('getRows')[3].value;
			var iconcls=$('#addnewft').propertygrid('getRows')[4].value;
			var functypedescribe=$('#addnewft').propertygrid('getRows')[5].value;
			var functypenum=$('#addnewft').propertygrid('getRows')[6].value;
			$.ajax({
				url:'addfunctype',
				type:'POST',
				data:{
					parentId:parentId,
					parentname:parentname,
					functypename:functypename,
					functypecode:functypecode,
					functypesort:functypesort,
					iconcls:iconcls,
					functypedescribe:functypedescribe,
					functypenum:functypenum
				},				
				success:function(data){
					alert(data.msg);
				}
			});
		}
	});
	
})